package com.gange.springboot.service.impl;

import com.gange.springboot.dao.UserMapper;
import com.gange.springboot.entity.User;
import com.gange.springboot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service //让spring 框架创建出一个当前类的对象  UserServiceImpl对象
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;//自动将UserMapper对象注入到当前对象里面
    @Override
    public User login(String name, String pwd) {
        return userMapper.selectByNameAndPwd(name,pwd);
    }

    @Override
    public void insert(User user) {
        userMapper.insert(user);
    }

    @Override
    public int delete(int id) {
        return userMapper.delete(id);
    }

    @Override
    public void update(User user) {
        userMapper.update(user);
    }

    @Override
    public List<User> selectAll() {
        return userMapper.selectAll();
    }

    @Override
    public User selectById(int id) {
        return userMapper.selectById(id);
    }
}
